home *** CD-ROM | disk | FTP | other *** search
- #ifndef FWEXCRUN_H
- #define FWEXCRUN_H
- //========================================================================================
- //
- // File: FWExcRun.h
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWEXCEPT_H
- #include "FWExcept.h"
- #endif
-
- #ifndef FWDELSTA_H
- #include "FWDelSta.h"
- #endif
-
- #ifndef FWEXCTAS_H
- #include "FWExcTas.h"
- #endif
-
- #ifdef FW_DEBUG
- #include <stdio.h>
- #endif
-
- class _FW_CTryBlockContext;
- class _FW_CPrivNewHelper;
- class _FW_CAutoDestructObject;
-
- //========================================================================================
- // Functions for "unexpected" and "terminate"
- //
- // See ARM, Section 15.6
- //========================================================================================
-
- extern void terminate();
- extern void unexpected();
-
- extern PFV set_terminate(PFV);
- extern PFV set_unexpected(PFV);
-
- //========================================================================================
- // CLASS _FW_CExceptionRuntime
- //========================================================================================
-
- class _FW_CExceptionRuntime
- {
- public:
- enum
- {
- kDefaultExceptionBufferSize = 128
- // Exception buffer size in bytes.
- // This limits size of largest exception object that may be thrown
- };
-
- static void Initialize(FW_SPrivExceptionGlobals& globals);
- static void Terminate();
-
- static void Throw(const _FW_CException & thrownException);
- static void ThrowSame();
- static void ThrowConstructor(_FW_CException & thrownException);
- static void ThrowSameConstructor();
- static void CaughtException(FW_SPrivExceptionGlobals& globals, _FW_CException * caughtException);
- static void CaughtEverythingException(FW_SPrivExceptionGlobals& globals);
- static void CaughtNoInstanceException(FW_SPrivExceptionGlobals& globals);
- static void CaughtReferenceException(FW_SPrivExceptionGlobals& globals);
- static void KeepThrowing(FW_SPrivExceptionGlobals& globals);
- static void CatchCleanup(FW_SPrivExceptionGlobals& globals);
- static void ResetExceptionBufferSize(size_t newSize);
- static PFV SetTerminate(PFV);
- static PFV SetUnexpected(PFV);
-
- static void EndConstructor(_FW_CAutoDestructObject *object, size_t size);
-
- #ifdef FW_DEBUG
- static FW_ClassReference SetBreakOnThrow(FW_ClassReference breakExceptionKind = NULL);
- static FW_ClassReference GetBreakOnThrow();
- #endif
-
- private:
- static void DeleteObjectsInContextAndJump(FW_SPrivExceptionGlobals& globals, _FW_CTryBlockContext * FWTryBlo);
- static void PrimitiveThrow(const _FW_CException & thrownException);
- static void PrimitiveThrowSame();
-
- };
-
- //========================================================================================
- // CLASS _FW_CExceptionRuntime INLINE Functions
- //========================================================================================
-
- #ifdef FW_DEBUG
- inline FW_ClassReference _FW_CExceptionRuntime::SetBreakOnThrow(FW_ClassReference breakExceptionKind)
- {
- FW_ClassReference previous = FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind;
- FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind = breakExceptionKind;
- return previous;
- }
- #endif
-
- #ifdef FW_DEBUG
- inline FW_ClassReference _FW_CExceptionRuntime::GetBreakOnThrow()
- {
- return FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind;
- }
- #endif
-
- //========================================================================================
- // CLASS _FW_CExceptionRuntime INLINE Functions (Platform-independent Versions)
- //========================================================================================
-
- inline void _FW_CExceptionRuntime::CatchCleanup(FW_SPrivExceptionGlobals& globals)
- {
- globals.gCaughtException = NULL;
- globals.gThrownException = NULL;
- }
-
- #endif
-